/*
 * @Author: [wsn] [1741415861@qq.com]
 * @Date: 2023-05-08 13:40:27
 * @LastEditors: [wsn] [1741415861@qq.com]
 * @LastEditTime: 2023-05-26 11:14:58
 * @FilePath: \202304fgs_project\src\components\threejsTools\Tools\splitmodel.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 详见游客端大雄殿index页面代码
// 拆解触发的方法---"FGS_DXD_ZJ_FGS_DXD_ZJ"为这个模型某mesh的名字，其他模型需要修改为对应名字
import TweenLite from "gsap";
import { Power4 } from "gsap";
/**模型拆解方法,window.globalmodel数据对应LoadFbx文件加载的模型 */
export const splitmodel = (bol) => {
    console.log('点击了拆解', window.globalmodel);
    // 为什么只有函数执行完，再点击一下屏幕，动一动模型界面，才会展示拆分效果呢？？
    if (bol) {
        window.globalmodel.traverse((child) => {
            console.log(child, "child");
            let yy = 0;
            if (child.isMesh) {
                if (child.name === "FGS_DXD_ZJ_FGS_DXD_ZJ") {
                    yy = 550;
                } else if (child.name === "FGS_QJ1_FGS_DXD_QJ_FGS_DXD_TS2") {
                    yy = 625;
                } else {
                    yy = 0;
                }
                TweenLite.to(child.position, 5, {
                    y: yy,
                    z: 0,
                    ease: Power4.easeOut,
                });
            }
        });
    }
    else{
        window.globalmodel.traverse((child) => {
            console.log(child, "child");
            let yy = 0;
            if (child.isMesh) {
                if (child.name === "FGS_DXD_ZJ_FGS_DXD_ZJ") {
                    yy = -250;
                } else if (child.name === "FGS_QJ1_FGS_DXD_QJ_FGS_DXD_TS2") {
                    yy = -325;
                } else {
                    yy = 0;
                }
                TweenLite.to(child.position, 5, {
                    y: 0,
                    z: 0,
                    ease: Power4.easeOut,
                });
            }
        });
    }

};